package com.study.talk.module.service.impl;

import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.study.talk.module.entity.Friend;
import com.study.talk.module.entity.InviteUserRecord;
import com.study.talk.module.mapper.InviteGroupRecordMapper;
import com.study.talk.module.mapper.InviteUserRecordMapper;
import com.study.talk.module.service.InviteUserRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class InviteUserRecordServiceImpl extends ServiceImpl<InviteUserRecordMapper, InviteUserRecord> implements InviteUserRecordService {

    @Resource
    private InviteUserRecordMapper inviteUserRecordMapper;

    @Override
    public void addInviteFriend(Integer userId, Integer friendId) {
        InviteUserRecord inviteUserRecord = new InviteUserRecord(userId, friendId);
        inviteUserRecordMapper.insert(inviteUserRecord);
    }

    @Override
    public void removeInviteFriend(Integer userId, Integer friendId) {
        inviteUserRecordMapper.removeInviteFriend(userId,friendId);
    }

    @Override
    public boolean queryHasInviteFriend(Integer userId, Integer friendId) {
        InviteUserRecord record = inviteUserRecordMapper.queryIsFriend(userId, friendId);
        return ObjectUtils.isNotNull(record);
    }
}
